[Back]

MacOS X Developer Preview 3 Release Notes Copyright © 2000 by Apple Computer, Inc. All Rights Reserved.

Mac OS X Developer Preview 3 Release Notes:
Altivec

 

The version of the c/cpp compiler shipped with Developer Preview 3 (based on egcs 1.1.2) has a bug compiling Altivec instructions. The VRSAVE register is not being maintained properly, causing vector registers to be corrupted during context switches. The problem becomes manifest when more than one thread is using Altivec. Because Core Graphics uses Altivec, if your app uses it too then it is likely that vector registers will occasionally be trashed. This will result in occasional bad pixels on the screen, as well as incorrect behavior of your app.

There are two approaches you can take to deal with this problem. One is to avoid using Altivec in Developer Preview 3, or at least to avoid using Altivec in C. The second approach is to install a temporary work around in your app's initialization:

unsigned int vrsavex = 0xFFFFFFFF;

__asm__ volatile("mtspr 256,%0" : : "r" (vrsavex));

This code marks all vector registers "in use" by loading -1 into VRSAVE, which forces the kernel to save and restore all the registers at each context switch. However, Core Graphics' registers remain unprotected, so occasional bad pixels will still occur while your app is running. If you choose to install this work around, be sure to remove it before your app ships, because saving and restoring all thirty two registers (512 bytes) at each context switch is quite slow.

This bug will be fixed in the next release of the compiler.